package com.googlecode.icecube.feedback;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

import com.googlecode.icefusion.ui.commons.BackingBeanForm;
import com.googlecode.icefusion.ui.commons.constant.ICEfusionConsts;
import com.googlecode.icefusion.ui.commons.form.IDadSelector;
import com.googlecode.icefusion.ui.commons.form.DadSelectorItem;

/**
 * Manages drag and drop examples.
 * 
 * @author Rainer Eschen
 *
 */
public class DragAndDrop extends BackingBeanForm implements IDadSelector {
	
	private static final long serialVersionUID = 3302834326725206605L;

	@Autowired
	private ICEfusionConsts consts;
	
	/**
	 * Entities that can be selected
	 */
	private ArrayList<DadSelectorItem> source;
	
	/**
	 * Selected entities
	 */
	private ArrayList<DadSelectorItem> selected = new ArrayList<DadSelectorItem>();
	
	/**
	 * Initialize the source array
	 */
	protected void init() {

		source = new ArrayList<DadSelectorItem>();
		selected = new ArrayList<DadSelectorItem>();
		
		DadSelectorItem item0 = new DadSelectorItem();
	/*	item0.setValue("0");
		item0.setLabel("-0-"); */
		item0.setImageUrl(consts.getContextPath() + consts.getSkinBase() + "/" + consts.getSkin() + "/images/messageDialog.png");
		source.add(item0);
		DadSelectorItem item1 = new DadSelectorItem();
	/*			item1.setValue("1");
		item1.setLabel("-1-"); */
		item1.setImageUrl(consts.getContextPath() + consts.getSkinBase() + "/" + consts.getSkin() + "/images/errorDialog.png");
		source.add(item1);
		DadSelectorItem item2 = new DadSelectorItem();
	/*		item2.setValue("2");
		item2.setLabel("-2-"); */
		item2.setImageUrl(consts.getContextPath() + consts.getSkinBase() + "/" + consts.getSkin() + "/images/questionDialog.png");
		source.add(item2);

		DadSelectorItem item3 = new DadSelectorItem();
			item3.setLabel("[A text-only entry]");
			source.add(item3);
	}
	
	public ArrayList<DadSelectorItem> getSource() {
		
		return source;
	}
	
	public void setSource(ArrayList<DadSelectorItem> source) {
		
		this.source = source;
	}
	
	public ArrayList<DadSelectorItem> getSelected() {
		
		return selected;
	}
	
	public void setSelected(ArrayList<DadSelectorItem> selected) {
		
		this.selected = selected;
	}
	
	public List<DadSelectorItem> getDadSelectorSelectedList() {
		
		return this.getSelected();
	}
	
	public List<DadSelectorItem> getDadSelectorSourceList() {

		if (this.getSource() == null) {
			this.init();
		}
		return this.getSource();
	}
}
